﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using LiveCharts;
using LiveCharts.Wpf;

namespace 数据挖掘实验
{
	public partial class MainWindow : Window
	{
		List<Grid> panels = new List<Grid>();
		public MainWindow()
		{
			Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
			InitializeComponent();
			InitialWindow();
			InitialBayes();
			InitialApriori();
		}

		void InitialWindow()
		{
			AddToPanelList(BayesPanel, true);
			AddToPanelList(AprioriPanel);
		}

		void AddToPanelList(Grid grid, bool display = false)
		{
			grid.Visibility = ConvertBoolToVisibility(display);
			panels.Add(grid);
		}

		void BayesUIGroupButton_Click(object sender, RoutedEventArgs e)
		{
			ShowPanel(BayesPanel);
		}

		void AprioriUIGroupButton_Click(object sender, RoutedEventArgs e)
		{
			ShowPanel(AprioriPanel);
		}

		void ShowPanel(Grid toPanel)
		{
			foreach (var panel in panels)
			{
				panel.Visibility = ConvertBoolToVisibility(panel == toPanel);
			}
		}

		/// <summary>
		/// 将布尔值转换为可视化信息
		/// </summary>
		/// <param name="visibility">是否可视</param>
		/// <returns>可视化信息</returns>
		Visibility ConvertBoolToVisibility(bool visibility)
		{
			return visibility ? Visibility.Visible : Visibility.Hidden;
		}
	}
}
